package org.ipower.examsystem.service.impl;

import java.util.List;
import org.ipower.examsystem.dao.ItemTypesDao;
import org.ipower.examsystem.domain.ItemTypes;
import org.ipower.examsystem.service.ItemTypeService;
import org.ipower.platform.domain.Pager;
import org.ipower.platform.domain.QueryCondition;

/**
 * 题型服务接口实现类。
 * @author young
 */
public class ItemTypeServiceImpl implements ItemTypeService {
    private static final long serialVersionUID = 1L;
    private ItemTypesDao dao = null;
    
    @Override
    public void setItemTypesDao(ItemTypesDao dao) {
         this.dao = dao;
    }

    @Override
    public Pager<ItemTypes> findAll(String ascProperty, boolean isAsc, int start, int limit, List<QueryCondition> entites) {
        return this.dao.findAll(ascProperty, isAsc, start, limit, entites);
    }

    @Override
    public List<ItemTypes> bindAllData() {
        return this.dao.bindAllData();
    }

    @Override
    public void saveOrUpdate(ItemTypes data) {
        if(data != null && data.getTypeID() != null && !data.getTypeID().isEmpty()){
            if(this.dao.load(data.getTypeID()) == null){
                this.dao.save(data);
            }else{
                this.dao.update(data);
            }
        }
    }

    @Override
    public void delete(String typeID) {
       if(typeID != null && !typeID.isEmpty()){
           this.dao.delete(typeID);
       }
    }
}